import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
// 页面
import './reorder_able_list_page.dart';
import './like_list_page.dart';
import './custom_list_page.dart';
import './nested_scroll_tabbar.dart';
import './tabbar_page.dart';
import './refresh_page/refresh_page.dart';
import './page_view_test/page_view_test.dart';

class ListPageRouteMap {
  final String reorderAbleListPage = 'reorder_able_list_page';
  final String likeListPage = 'like_list_page';
  final String customListPage = 'custom_list_page';
  final String nestedScrollTabbar = 'nested_scroll_tabbar';
  final String tabbarPage = 'tabbar_page';
  final String refreshPage = 'refresh_page';
  final String pageViewTest = 'page_view_test';

  static void Function(FluroRouter) define = handleDefine;
}

void handleDefine(FluroRouter router) {
  ListPageRouteMap routeMap = ListPageRouteMap();

  router.define(
    routeMap.reorderAbleListPage,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return ReorderAbleListPage();
      },
    ),
  );

  router.define(
    routeMap.likeListPage,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        String list = '';
        if (params.containsKey('list') && params['list']?.first != null) {
          list = params['list']!.first;
        }

        return LikeListPage(
          list: list,
        );
      },
    ),
  );

  router.define(
    routeMap.customListPage,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return CustomListPage();
      },
    ),
  );

  router.define(
    routeMap.nestedScrollTabbar,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return NestedScrollTabbar();
      },
    ),
  );

  router.define(
    routeMap.tabbarPage,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return TabbarPage();
      },
    ),
  );

  router.define(
    routeMap.refreshPage,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return RefreshPage();
      },
    ),
  );

  router.define(
    routeMap.pageViewTest,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return PageViewTest();
      },
    ),
  );
}
